package com.shengyuan.manage_os.old.ying.erpm;

import com.shengyuan.manage_os.R;
import com.shengyuan.manage_os.old.ying.boce.jsy.APIErpm;
import com.shengyuan.manage_os.old.ying.erpm.db.Actual_Data_Table;
import com.shengyuan.manage_os.old.ying.erpm.util.Utility;

import android.app.Activity;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class About extends Activity implements OnClickListener {

	private Button btn_about_back;
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_about_back:
			finish();
			break;
		default:
			break;
		}
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.form_about);
		initcontrols();
		
	}
	private void initcontrols() {
		btn_about_back = (Button) findViewById(R.id.btn_about_back);
		btn_about_back.setOnClickListener(this);
		
		TextView editText;
		editText = (TextView) findViewById(R.id.editText_versionCode);
		String s="";
		try {
			s = this.getPackageManager().getPackageInfo( getPackageName(), 0).versionCode+"";
			editText.setText(s);
			
			editText = (TextView) findViewById(R.id.editText_versionName);
			s = this.getPackageManager().getPackageInfo( getPackageName(), 0).versionName;
			editText.setText(s);			
			
			editText = (TextView) findViewById(R.id.editText_produce_model);
			s = android.os.Build.MODEL + "," 
	                + android.os.Build.VERSION.SDK + "," 
	                + android.os.Build.VERSION.RELEASE;
			editText.setText(s);

			if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
				editText = (TextView) findViewById(R.id.editText_sdsize);
				s = "剩:"+Utility.getSDFreeSize(true) +"MB/总:"+ Utility.getSDAllSize(true)+"MB";
				editText.setText(s);				
			}
			editText = (TextView) findViewById(R.id.editText_intersize);
			s = "剩:"+Utility.getSDFreeSize(false) +"MB/总:"+ Utility.getSDAllSize(false)+"MB";
			editText.setText(s);	
			
			editText = (TextView) findViewById(R.id.editText_produce_net);
			APIErpm api = new APIErpm();
			s = api.baseURL;
			editText.setText(s);	
			
			Actual_Data_Table dbo = new Actual_Data_Table(MainApplication.Instance);
			int i = dbo.get_Sended_rows("0" );
			int k = dbo.get_Sended_rows("1");
			
			editText = (TextView) findViewById(R.id.editText_datarow);
			editText.setText("数据:" + i + "/照片:" + k);			
			
			editText = (TextView) findViewById(R.id.editText_baidupushrow);
			editText.setText( "@@@");
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}
		
	}
	

}
